package greetings

import (
	"fmt"
	"time"
)

func spinner(delay time.Duration) {
	for {
		for _, r := range `-\|/-` {
			fmt.Printf("\r%c", r)
			time.Sleep(delay)
		}
	}
}

func spinner2(delay time.Duration) {
	arr := [...]string{".          ", "..         ", "...       ", "....      ", ".....     ", "......    ", ".......   ", "........  ", "......... "}
	for {
		for _, r := range arr {
			fmt.Printf("\r%s", r)
			time.Sleep(delay)
		}
	}
}

func spinner3() {
	arr := [...]string{"          ", ".        ", "..        ", "...       ", "....      ", ".....     ", "......    ", ".......   ", ".........  ", "......... ", ".........."}
	for {
		var i time.Duration
		i = 10
		for _, r := range arr {
			fmt.Printf("\r%s", r)
			time.Sleep(time.Second / i)
			i++
		}

		i = 6
		for k := len(arr) - 1; k >= 0; k-- {
			fmt.Printf("\r%s", arr[k])
			time.Sleep(2 * time.Second / i)
			i++
		}
	}
}

func animation() {

	spinner(100 * time.Millisecond)
}
func animation2() {

	spinner2(300 * time.Millisecond)
}

func Animation3() {

	spinner3()
}
